import { createRouter, createWebHistory } from 'vue-router'
import Login from './views/Login.vue'
import Register from './views/Register.vue'
// 引入管理员页面
import AdminDashboard from './views/admin/AdminDashboard.vue'
import AdminUsers from './views/admin/AdminUsers.vue'
// 引入普通用户页面
import UserDashboard from './views/user/UserDashboard.vue'

const routes = [
  {
    path: '/',
    name: 'login',
    component: Login
  },
  {
    path: '/login',
    redirect: '/'
  },
  {
    path: '/register',
    name: 'register',
    component: Register
  },
  {
    path: '/admin',
    name: 'admin',
    component: AdminDashboard,
    children: [
      {
        path: 'surveys',
        name: 'admin-surveys',
        // 暂时代替不存在的组件
        component: {
          render: () => document.createElement('div') // 空组件占位符
        }
      },
      {
        path: 'users',
        name: 'admin-users',
        component: AdminUsers
      },
      {
        path: 'settings',
        name: 'admin-settings',
        // 暂时代替不存在的组件
        component: {
          render: () => document.createElement('div') // 空组件占位符
        }
      }
    ]
  },
  {
    path: '/user-dashboard',
    name: 'user-dashboard',
    component: UserDashboard
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router